import subprocess

from items import init_items
from utils import dict_to_sbar_args


def init_bar():
    sketchybar_bar = dict_to_sbar_args(
        {
            "height": 36,
            "color": "0xF02C2E34",
            "padding_right": 2,
            "padding_left": 2,
            "topmost": "window",
            "position": "bottom",
        }
    )
    subprocess.run(["sketchybar", "--bar", *sketchybar_bar])


def init_default():
    default_config = dict(
        updates="when_shown",
        icon=dict(
            font=dict(
                family="SF Pro",
                style="Bold",
                size=14.0,
            ),
            color="0xffffffff",
            padding_left=3,
            padding_right=3,
        ),
        label=dict(
            font=dict(
                family="SF Pro",
                style="Semibold",
                size=13.0,
            ),
            color="0xffffffff",
            padding_left=3,
            padding_right=3,
        ),
        background=dict(
            height=28,
            corner_radius=9,
            border_width=2,
            border_color="0xFF414550",
            image=dict(
                corner_radius=9,
                border_color="0xFF7F8490",
                border_width=1,
            ),
        ),
        popup=dict(
            background=dict(
                border_width=2,
                corner_radius=9,
                border_color="0xFF7F8490",
                color="0xC02C2E34",
                shadow=dict(
                    drawing=True,
                ),
            ),
            blur_radius=50,
        ),
        padding_left=5,
        padding_right=5,
        scroll_texts=True,
    )
    subprocess.run(
        ["sketchybar", "-m", "--default", *dict_to_sbar_args(default_config)]
    )


def init():
    init_bar()
    init_default()
    init_items()
